import Vue from 'vue'
import MinRequest from '@/utils/MinRequest'

const minRequest = new MinRequest()
// 请求拦截器
minRequest.interceptors.request((request) => {
	let cookie  =  uni.getStorageSync('setUserData').session_id;
	request.header.cookie = cookie;
	return request
})
// 响应拦截器
minRequest.interceptors.response((response) => {
	if (response.statusCode !== 200) {
		let msg = ''
		if (response.data.error = 500) {
			msg = response.data.msg
		} else {
			msg = '请求超时，请检查网络配置'
		}
		uni.showToast({
			title: msg,
			icon: 'none'
		})
	}
	return response.data
})



// 设置默认配置

// 设置默认配置
minRequest.setConfig((config) => {
  config.baseURL = 'http://127.0.0.1:8078/api'
  return config
})
 
export default {
  // 这里统一管理api请求
  apis: {
    login (data) {
      return minRequest.post('/login', data)
    },
	updataHelp (data) {
	  return minRequest.post('/updateHelpStatus', data)
	},
	getHelp (data) {
	  return minRequest.get('/getHelp', data)
	},
	getHelpDesc (data) {
	  return minRequest.get('/getHelpDesc', data)
	},
	addHelp(data) {
	  return minRequest.post('/addHelp', data)
	},
	getShareDesc (data) {
	  return minRequest.get('/getShareDesc', data)
	},
	getShare (data) {
	  return minRequest.get('/getShare', data)
	},
	addShare (data) {
	  return minRequest.post('/addShare', data)
	},
	getComplaint(data){
		return minRequest.get('/getComplaintList', data)
	},
	addComplaint(data){
		return minRequest.post('/addComplaint', data)
	},
	getComplaintDesc(data){
		return minRequest.get('/getComplaintDesc', data)
	},
	commentList(data){
		return minRequest.post('/commentList', data)
	},
	commentSend(data){
		return minRequest.post('/commentSend', data)
		}
	},
	getCommentById(data){
		return minRequest.post('/getCommentById', data)
	}
	
}